package ve.ejb.entity;

import ve.ejb.metadata.DimensionMember;
import ve.ejb.metadata.Comparator;
import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.Enumerated;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author memozac
 */
@Entity
public class DimensionalCut extends Pointer implements Serializable {
    private static final long serialVersionUID = 1L;

    public enum Type{TOTAL,STANDARD};

    @ManyToOne private Pointer pointer;

    @ManyToMany(targetEntity=Comparator.class) @JoinTable(name="ComparatorDimensionalCut", joinColumns=@JoinColumn(name="idDimensionalCut"),
    inverseJoinColumns=@JoinColumn(name="idComparator")) private Collection<Comparator> registers;

    @ManyToMany(targetEntity=DimensionMember.class) @JoinTable(name="DimensionalCutMember", joinColumns=@JoinColumn(name="idDimensionalCut"),
    inverseJoinColumns=@JoinColumn(name="idDimensionMember")) private Collection<DimensionMember> dimensionMembers;

    @Enumerated private Type type;

    @Temporal(value = TemporalType.TIMESTAMP) private Date registerDate;

    public Date getRegisterDate() {
        return registerDate;
    }

    public void setRegisterDate(Date registerDate) {
        this.registerDate = registerDate;
    }

    public Collection<DimensionMember> getDimensionMembers() {
        return dimensionMembers;
    }

    public void setDimensionMembers(Collection<DimensionMember> dimensionMembers) {
        this.dimensionMembers = dimensionMembers;
    }

    public Type getType() {
        return type;
    }

    public void setType(Type type) {
        this.type = type;
    }

    public Pointer getPointer() {
        return pointer;
    }

    public void setPointer(Pointer pointer) {
        this.pointer = pointer;
    }

    public Collection<Comparator> getRegisters() {
        return registers;
    }

    public void setRegisters(Collection<Comparator> registers) {
        this.registers = registers;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idScoreCard != null ? idScoreCard.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof DimensionalCut)) {
            return false;
        }
        DimensionalCut other = (DimensionalCut) object;
        if ((this.idScoreCard == null && other.idScoreCard != null) || (this.idScoreCard != null && !this.idScoreCard.equals(other.idScoreCard))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "ve.ejb.entity.DimensionalCut[id=" + idScoreCard + "]";
    }

}//ends of class
